<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  

  
  <title>Java 加密算法（二） | 海晨忆的博客</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  
  
  
  <meta name="description" content="补充知识点：密钥： 加密方用公钥，解密方用私钥 重要的事情强调六遍： 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法">
<meta property="og:type" content="article">
<meta property="og:title" content="Java 加密算法（二）">
<meta property="og:url" content="https://haichenyi.com/2018/05/13/Java-加密算法（二）/index.html">
<meta property="og:site_name" content="海晨忆的博客">
<meta property="og:description" content="补充知识点：密钥： 加密方用公钥，解密方用私钥 重要的事情强调六遍： 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法">
<meta property="og:locale" content="zh-Hans">
<meta property="og:updated_time" content="2018-05-13T14:24:05.502Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Java 加密算法（二）">
<meta name="twitter:description" content="补充知识点：密钥： 加密方用公钥，解密方用私钥 重要的事情强调六遍： 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法 不用自己写加密算法">
  
    <link rel="alternate" href="/atom.xml" title="海晨忆的博客" type="application/atom+xml">
  
  
    <link rel="icon" href="/uploads/artistic_image/head.jpg">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="/css/style.css">
  <link rel="stylesheet" href="/css/highlight.css">
  <script>
  let antiquityStorage = window.sessionStorage.getItem('antiquitySessionStorage');
  if (antiquityStorage == '' || antiquityStorage == null) {
    var antiquityLoader = '<div id="loaderbox"><div class="loader"><div class="load-roll"><div class="load-top"></div><div class="load-right"></div><div class="load-bottom"></div></div></div></div>';
    document.write(antiquityLoader);
    document.body.style.overflow = 'hidden'
  }
  </script>
</head>

<body>
  <div id="fullpage" class="mobile-nav-right">
    
      <div id="wrapper" style="background-image: url(/uploads/artistic_image/bg.jpg)" title="背景图片来自网络">
    
    
      <header id="header">
  <div id="nav-toggle" class="nav-toggle"></div>
  <div class="head-box global-width">
    <nav class="nav-box nav-right">
      
        <a class="nav-item" href="/" title
        
        >首页</a>
      
        <a class="nav-item" href="/archives" title
        
        >归档</a>
      
        <a class="nav-item" href="/about" title
        
        >简历</a>
      
    </nav>
  </div>
</header>
      <div id="middlecontent" title class="global-width sidebar-left">
        <section id="main"><article id="post-Java-加密算法（二）" class="article global-container article-type-post" itemscope itemprop="blogPost">
  
    <header class="article-header">
      
  
    <h1 class="article-title" itemprop="name">
      Java 加密算法（二）
    </h1>
  

    </header>
  
  <div class="article-meta">
    <a href="/2018/05/13/Java-加密算法（二）/" class="article-date">
  <time datetime="2018-05-13T14:22:11.000Z" itemprop="datePublished">2018-05-13</time>
</a>
    
  <div class="article-category">
    <a class="article-category-link" href="/categories/Android-加密算法/">Android -加密算法</a>
  </div>

    
  </div>
  
    <span id="busuanzi_container_page_pv">
      本文总阅读量<span id="busuanzi_value_page_pv"></span>次
    </span>
  

  <div class="article-inner">
    
    <div class="article-content article-content-cloud doorframe mac" itemprop="articleBody">
      
        <h2 id="补充知识点："><a href="#补充知识点：" class="headerlink" title="补充知识点："></a>补充知识点：</h2><p><strong><em>密钥：</em></strong> 加密方用公钥，解密方用私钥</p>
<p><strong>重要的事情强调六遍：</strong></p>
<p><strong><em>不用自己写加密算法</em></strong></p>
<p><strong><em>不用自己写加密算法</em></strong></p>
<p><strong><em>不用自己写加密算法</em></strong></p>
<p><strong><em>不用自己写加密算法</em></strong></p>
<p><strong><em>不用自己写加密算法</em></strong></p>
<p><strong><em>不用自己写加密算法</em></strong></p>
<a id="more"></a>
<h3 id="Cipher类"><a href="#Cipher类" class="headerlink" title="Cipher类"></a>Cipher类</h3><p>&emsp;&emsp;Android有专门用来加密的工具类Cipher类，他里面封装了几种常用的加密算法，本篇介绍两种AES，RSA。</p>
<p><strong><em>用法</em></strong></p>
<div class="highlight-box"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br></pre></td><td class="code"><pre><span class="line">分三步：以AES举例说明</span><br><span class="line"></span><br><span class="line">  /**</span><br><span class="line">   * 加密方式：AES</span><br><span class="line">   * 工作模式：ECB,CBC,CTR,OFB,CFB</span><br><span class="line">   * 填充模式：PKCS5Padding，PKCS7Padding，ZEROPadding等等</span><br><span class="line">   */</span><br><span class="line">String CBC_PKCS5_PADDING = &quot;AES/CBC/PKCS5Padding&quot;;//AES是加密方式 CBC是工作模式 PKCS5Padding是填充模式</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">//第一步：获取对象</span><br><span class="line">Cipher cipher = Cipher.getInstance(String transformation);//传 CBC_PKCS5_PADDING</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">//第二步：设置初始化参数</span><br><span class="line">    /**</span><br><span class="line">     * 第一个参数：传类型，是加密Cipher.ENCRYPT_MODE，还是解密Cipher.DECRYPT_MODE</span><br><span class="line">     * 第二个参数：传密钥key，我们这里传的是SecretKeySpec，它实现SecretKey，SecretKey实现Key接口。</span><br><span class="line">     *             SecretKeySpec keySpec = new SecretKeySpec(raw, AES);//第一个参数传密钥byte数组，第二个参数传加密类型也就是&quot;AES&quot;字符串即可</span><br><span class="line">     * 第三个参数：传偏移量AlgorithmParameterSpec，我们这里传的IvParameterSpec，他实现AlgorithmParameterSpec接口，iv偏移量传默认的16个0的字节数组</span><br><span class="line">     *              new IvParameterSpec(new byte[cipher.getBlockSize()])，这里是传的默认的16个0的byte数组，也是常用的方式</span><br><span class="line">     */</span><br><span class="line">cipher.init(int opmode, Key key, AlgorithmParameterSpec params)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">第三步：加密。传需要加密的字符串的byte数组</span><br><span class="line">cipher.doFinal(byte[] input)</span><br><span class="line"></span><br><span class="line">经过以上三步：AES加密就算完成了，加密之后就需要解密，辣么，怎么解密呢？</span><br><span class="line"></span><br><span class="line">    草鸡简单，第二步初始化的时候，第一个参数传解密即可，其他都是一样的。</span><br></pre></td></tr></table></figure></div>
<h2 id="对称加密"><a href="#对称加密" class="headerlink" title="对称加密"></a>对称加密</h2><h3 id="概念"><a href="#概念" class="headerlink" title="概念"></a>概念</h3><p>出自百度百科</p>
<p>&emsp;&emsp;需要对加密和解密使用相同密钥的加密算法。由于其速度快，对称性加密通常在消息发送方需要加密大量数据时使用。对称性加密也称为密钥加密。</p>
<p>&emsp;&emsp;所谓对称，就是采用这种加密方法的双方使用方式用同样的密钥进行加密和解密。密钥是控制加密及解密过程的指令。算法是一组规则，规定如何进行加密和解密。</p>
<p>&emsp;&emsp;因此，加密的安全性不仅取决于加密算法本身，密钥管理的安全性更是重要。因为加密和解密都使用同一个密钥，如何把密钥安全地传递到解密者手上就成了必须要解决的问题。</p>
<p>&emsp;&emsp;说了这么多废话，要我说，就一句话公钥，私钥 <strong><em>相同</em></strong> 的加密方式称之为对称加密</p>
<h2 id="用法——AES"><a href="#用法——AES" class="headerlink" title="用法——AES"></a>用法——AES</h2><p>&emsp;&emsp;申明：我这里并不是说对称加密就只有AES这一种方式，相反，对称加密有很多种，我这里只讲我用到的对称加密中的一种方式——AES</p>
<div class="highlight-box"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">  private static final String CBC_PKCS5_PADDING = &quot;AES/CBC/PKCS5Padding&quot;;//AES是加密方式 CBC是工作模式 PKCS5Padding是填充模式</span><br><span class="line">  private static final String AES = &quot;AES&quot;;//AES 加密</span><br><span class="line">  private static final String SHA1PRNG = &quot;SHA1PRNG&quot;;// SHA1PRNG 强随机种子算法, 要区别4.2以上版本的调用方法</span><br><span class="line"></span><br><span class="line">/**</span><br><span class="line">   * 随机生成密钥，传同一个字符串，每次都生成的不一样</span><br><span class="line">   * @param seed 一般传用户的密码</span><br><span class="line">   * @return 返回密钥的byte数组</span><br><span class="line">   * @throws Exception 异常</span><br><span class="line">   */</span><br><span class="line">  private static byte[] getRawKey(String seed) throws Exception &#123;</span><br><span class="line">    SecureRandom sr = null;</span><br><span class="line">    // 在4.2以上版本中，SecureRandom获取方式发生了改变</span><br><span class="line">    if (android.os.Build.VERSION.SDK_INT &gt;= 17) &#123;</span><br><span class="line">      sr = SecureRandom.getInstance(SHA1PRNG, &quot;Crypto&quot;);</span><br><span class="line">    &#125; else &#123;</span><br><span class="line">      sr = SecureRandom.getInstance(&quot;SHA1PRNG&quot;); // 获得一个随机数，传入的参数为默认方式。</span><br><span class="line">    &#125;</span><br><span class="line">    sr.setSeed(seed.getBytes());  // 设置一个种子，这个种子一般是用户设定的密码。也可以是其它某个固定的字符串</span><br><span class="line">    KeyGenerator keyGen = KeyGenerator.getInstance(&quot;AES&quot;);  // 获得一个key生成器（AES加密模式）</span><br><span class="line">    //AES中128位密钥版本有10个加密循环，192比特密钥版本有12个加密循环，256比特密钥版本则有14个加密循环。</span><br><span class="line">    keyGen.init(128, sr);      // 设置密匙长度128位</span><br><span class="line">    SecretKey key = keyGen.generateKey();  // 获得密匙</span><br><span class="line">    return key.getEncoded();</span><br><span class="line">  &#125;</span><br><span class="line">  </span><br><span class="line">  </span><br><span class="line">  /**</span><br><span class="line">   * 加密过程</span><br><span class="line">   * @param raw 密钥的数组</span><br><span class="line">   * @param clear 需要加密的byte数组</span><br><span class="line">   * @return 加密后的byte数组</span><br><span class="line">   * @throws Exception 异常</span><br><span class="line">   */</span><br><span class="line">  private static byte[] encrypt(byte[] raw, byte[] clear) throws Exception &#123;</span><br><span class="line">    SecretKeySpec keySpec = new SecretKeySpec(raw, AES);</span><br><span class="line">    Cipher cipher = Cipher.getInstance(CBC_PKCS5_PADDING);</span><br><span class="line">    //iv偏移量传默认的16个0的字节数组</span><br><span class="line">    cipher.init(Cipher.ENCRYPT_MODE, keySpec, new IvParameterSpec(new byte[cipher.getBlockSize()]));</span><br><span class="line">    return cipher.doFinal(clear);</span><br><span class="line">  &#125;</span><br><span class="line">  </span><br><span class="line">  </span><br><span class="line">  /*</span><br><span class="line">   * 解密</span><br><span class="line">   */</span><br><span class="line">  private static byte[] decrypt(byte[] raw, byte[] encrypted) throws Exception &#123;</span><br><span class="line">    SecretKeySpec keySpec = new SecretKeySpec(raw, AES);</span><br><span class="line">    Cipher cipher = Cipher.getInstance(CBC_PKCS5_PADDING);</span><br><span class="line">    cipher.init(Cipher.DECRYPT_MODE, keySpec, new IvParameterSpec(new byte[cipher.getBlockSize()]));</span><br><span class="line">    return cipher.doFinal(encrypted);</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure></div>
<p>&emsp;&emsp;上面给的三个方法，一个获取密钥，一个加密，一个解密，注释写的很清楚，我就不用再讲了，转16进制的方法，我前一篇讲加密的时候就给出来了，不知道的可以去前一篇看一下，我下面给出调用方式和结果截图</p>
<div class="highlight-box"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">try &#123;</span><br><span class="line">       byte[] rawKey = getRawKey(key);</span><br><span class="line">       Log.v(&quot;wz&quot;, rawKey.length + &quot;&quot;);</span><br><span class="line">       String s = bytesToHexFun1(rawKey);</span><br><span class="line">       Log.v(&quot;wz&quot;,&quot;密钥16进制--&gt;&quot;+s);</span><br><span class="line">       byte[] encrypt = encrypt(rawKey, data.getBytes());</span><br><span class="line">       String after = Base64.encodeToString(encrypt, Base64.NO_WRAP);</span><br><span class="line">       Log.v(&quot;wz&quot;,&quot;加密后--&gt;&quot;+after);</span><br><span class="line">       byte[] decode = Base64.decode(after, Base64.NO_WRAP);</span><br><span class="line">       byte[] before = decrypt(rawKey, decode);</span><br><span class="line">       Log.v(&quot;wz&quot;,&quot;解密后--&gt;&quot;+new String(before));</span><br><span class="line">     &#125; catch (Exception e) &#123;</span><br><span class="line">       e.printStackTrace();</span><br><span class="line">     &#125;</span><br></pre></td></tr></table></figure></div>
<p>结果：</p>
<h2 id="非对称加密"><a href="#非对称加密" class="headerlink" title="非对称加密"></a>非对称加密</h2><h3 id="概念-1"><a href="#概念-1" class="headerlink" title="概念"></a>概念</h3><p>出自百度百科</p>
<p>&emsp;&emsp;1976年，美国学者Dime和Henman为解决信息公开传送和密钥管理问题，提出一种新的密钥交换协议，允许在不安全的媒体上的通讯双方交换信息，安全地达成一致的密钥，这就是“公开密钥系统”。</p>
<p>&emsp;&emsp;与对称加密算法不同，非对称加密算法需要两个密钥：公开密钥（publickey）和私有密钥（privatekey）。公开密钥与私有密钥是一对，如果用公开密钥对数据进行加密，只有用对应的私有密钥才能解密；如果用私有密钥对数据进行加密，那么只有用对应的公开密钥才能解密。因为加密和解密使用的是两个不同的密钥，所以这种算法叫作非对称加密算法。</p>
<p>&emsp;&emsp;说了这么多废话，要我说，就一句话公钥，私钥 <strong><em>不相同</em></strong> 的加密方式称之为对称加密</p>
<h2 id="用法——RSA"><a href="#用法——RSA" class="headerlink" title="用法——RSA"></a>用法——RSA</h2><p>&emsp;&emsp;申明：我这里并不是说非对称加密就只有RSA这一种方式，相反，对非称加密有很多种，我这里只讲我用到的非对称加密中的一种方式——RSA</p>
<p>&emsp;&emsp;辣么，成对公钥，私钥怎么来呢？难道我们自己去写吗？你要是会写，那你很棒棒哦，反正我不会(爱咋咋)，我是<a href="http://web.chacuo.net/netrsakeypair" target="_blank" rel="noopener">在线生成公钥，私钥对</a>。用法跟上面讲的AES是类似的：</p>
<div class="highlight-box"autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" contenteditable="true"data-rel="PLAIN"><figure class="iseeu highlight /plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line">   * 我们之前拿到的是公钥，我们还要把公钥转成Key</span><br><span class="line">   * 因为cipher.init()初始化的时候，第二个参数需要传Key类型的，并不是String</span><br><span class="line">   * 获取Key，我这里返回的是PublicKey，它实现的Key接口</span><br><span class="line">   * @param pubKey 生成的公钥</span><br><span class="line">   * @return 最后需要的key</span><br><span class="line">   * @throws Exception 异常</span><br><span class="line">   */</span><br><span class="line">  public static PublicKey loadPublicKey(String pubKey) throws Exception &#123;</span><br><span class="line">    byte[] buffer = Base64.decode(pubKey, Base64.DEFAULT);</span><br><span class="line">    KeyFactory keyFactory = KeyFactory.getInstance(&quot;RSA&quot;);</span><br><span class="line">    X509EncodedKeySpec keySpec = new X509EncodedKeySpec(buffer);</span><br><span class="line">    return keyFactory.generatePublic(keySpec);</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  /**</span><br><span class="line">   * 加密</span><br><span class="line">   * @param data 需要加密的数据</span><br><span class="line">   * @param publicKey key</span><br><span class="line">   * @return 返回加密后的byte，需要转成字符串</span><br><span class="line">   * @throws Exception 异常</span><br><span class="line">   */</span><br><span class="line">  private static byte[] encryptRSA(String data,PublicKey publicKey) throws Exception &#123;</span><br><span class="line">    Cipher cipher = Cipher.getInstance(&quot;RSA/ECB/PKCS1Padding&quot;);</span><br><span class="line">    cipher.init(Cipher.ENCRYPT_MODE,publicKey);</span><br><span class="line">    return cipher.doFinal(data.getBytes());</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  /**</span><br><span class="line">   * 解密（我们需要注意的是，我们解密的是私钥加密的数据，不能解密公钥加密的数据）</span><br><span class="line">   * @param data 需要解密的数据</span><br><span class="line">   * @param publicKey key</span><br><span class="line">   * @return 返回解密后的数组</span><br><span class="line">   * @throws Exception 异常</span><br><span class="line">   */</span><br><span class="line">  private static byte[] decryptRSA(String data,PublicKey publicKey) throws Exception &#123;</span><br><span class="line">    Cipher cipher = Cipher.getInstance(&quot;RSA/ECB/PKCS1Padding&quot;);</span><br><span class="line">    cipher.init(Cipher.DECRYPT_MODE,publicKey);</span><br><span class="line">    return cipher.doFinal(data.getBytes());</span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure></div>
<p>&emsp;&emsp;这里，注释说的很清楚，看懂了前面的AES，辣么，这个RSA应该不是问题。</p>

      
    </div>
    
      <footer class="article-footer">
        完
      </footer>
    
  </div>
  
    
<nav id="article-nav">
  <div class="article-nav-block">
    
      <a href="/2018/05/13/Android下拉刷新，上拉加载——Ultra-Pull-To-Refresh-With-Load-More（一）/" id="article-nav-newer" class="article-nav-link-wrap">
        <strong class="article-nav-caption"></strong>
        <div class="article-nav-title">
          
            Android下拉刷新，上拉加载——Ultra-Pull-To-Refresh-With-Load-More（一）
          
        </div>
      </a>
    
  </div>
  <div class="article-nav-block">
    
      <a href="/2018/03/08/Java-加密算法（一）/" id="article-nav-older" class="article-nav-link-wrap">
        <div class="article-nav-title">Java 加密算法（一）</div>
        <strong class="article-nav-caption"></strong>
      </a>
    
  </div>
</nav>

    
  
  
</article>
</section>
        <aside id="sidebar">
  
    <div class="widget-box">
  <div class="avatar-box avatar-item">
    <img class="avatar" src="/uploads/artistic_image/head.jpg" title="头像来自网络"></img>
    <h3 class="avatar-name">
      
        海晨忆
      
    </h3>
    <p class="avatar-slogan">
      先谋生，再谋爱。人间值得，未来可期。
    </p>
  </div>
</div>


  
    
  <div class="widget-box">
    <h3 class="widget-title">分类</h3>
    <div class="widget">
      <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Android-Socket/">Android -Socket</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android-加密算法/">Android -加密算法</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android-常用功能/">Android -常用功能</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android-框架/">Android -框架</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android-源码解析/">Android -源码解析</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android-自定义view/">Android -自定义view</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Android-设计模式/">Android -设计模式</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/JAVA-并发/">JAVA -并发</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Java-SpringBoot/">Java -SpringBoot</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/Tomcat/">Tomcat</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/kotlin/">kotlin</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/数据库-JDBC/">数据库 -JDBC</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/数据库-MySQL/">数据库 -MySQL</a></li></ul>
    </div>
  </div>


  
    

  
    
  
    
  <div class="widget-box">
    <h3 class="widget-title">归档</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2021/07/">July 2021</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/11/">November 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/10/">October 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/09/">September 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/08/">August 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/07/">July 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2019/06/">June 2019</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/10/">October 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/05/">May 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/03/">March 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2018/02/">February 2018</a></li></ul>
    </div>
  </div>

  
    
  <div class="widget-box">
    <h3 class="widget-title">最新文章</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="/2021/07/27/JAVA—公平锁，非公平锁，悲观锁，乐观锁，死锁/">JAVA—公平锁，非公平锁，悲观锁，乐观锁，死锁</a>
          </li>
        
          <li>
            <a href="/2021/07/19/JAVA—线程同步器AQS/">JAVA—线程同步器AQS</a>
          </li>
        
          <li>
            <a href="/2021/07/07/Android模拟点击/">Android模拟点击</a>
          </li>
        
          <li>
            <a href="/2019/11/27/SpringBoot系列-消息-RabbitMQ-（二十）/">SpringBoot系列-消息(RabbitMQ)（二十）</a>
          </li>
        
          <li>
            <a href="/2019/11/13/SpringBoot系列-Docker（十九）/">SpringBoot系列-Docker（十九）</a>
          </li>
        
      </ul>
    </div>
  </div>

  
      <div class="widget-box">
    <h3 class="widget-title">友情链接</h3>
    <div class="widget">
      
        <a class="hrf" style="display: block;" href="https://github.com/haichenyi" title target='_blank'
        >Github</a>
      
        <a class="hrf" style="display: block;" href="https://www.jianshu.com/u/6077ee440c37" title target='_blank'
        >简书</a>
      
        <a class="hrf" style="display: block;" href="https://blog.csdn.net/qq_27634797" title target='_blank'
        >CSDN</a>
      
    </div>
  </div>

  
</aside>
      </div>
      <footer id="footer">
  <div class="foot-box footers global-width">
    &copy;2017-2021 海晨忆 &nbsp;&nbsp;
    <script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span id="busuanzi_container_site_pv">阁下是第<span id="busuanzi_value_site_pv"></span>个访客</span>
  </div>
</footer>
      <script src="https://code.jquery.com/jquery-2.0.3.min.js"></script>
<script>
if (!window.jQuery) {
var script = document.createElement('script');
script.src = "/js/jquery-2.0.3.min.js";
document.body.write(script);
}
</script>

  <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  <script src="/fancybox/jquery.fancybox.pack.js"></script>


<script src="/js/script.js"></script>



    </div>
    <nav id="mobile-nav" class="mobile-nav-box">
  <div class="mobile-nav-img mobile-nav-top"></div>
  
    <a href="/" class="mobile-nav-link">首页</a>
  
    <a href="/archives" class="mobile-nav-link">归档</a>
  
    <a href="/about" class="mobile-nav-link">简历</a>
  
  <div class="mobile-nav-img  mobile-nav-bottom"></div>
</nav>    
  </div>
</body>
</html>